﻿/*************************************************************************
 * 模块名称:   As标准图形模块
 * 作者:       姜一
 * 创建时间:   2023年3月
 * 最近修改:   2023年4月2日
 * 描述:       此模块不考虑复杂情况，只提供通用标准的使用内容，不冗余封装，不作为定制产品。
 * 留言:       此模块由姜一完全开发，如有修改建议或疑问请与作者咨询。
**************************************************************************/
#pragma once
#include "AsGraphicsGlobal.h"
#include <QPen>
#include <QBrush>
#include <QGraphicsView>
#include <QShowEvent>
#include <QResizeEvent>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QDragEnterEvent>
#include <QDragLeaveEvent>
#include <QDropEvent>
#include <QGraphicsLineItem>
#include <QGraphicsRectItem>
#include <QGraphicsEllipseItem>
#include <QGraphicsPolygonItem>
#include <QGraphicsSimpleTextItem>
#include <QGraphicsTextItem>
#include <QGraphicsPixmapItem>
#define AG_WINDOW_PREPARE_TIME 100
#define AG_INC_OPENCV
/*
	设计：
		1.尽量不要使用私有成员的析构函数

*/

class AsGraphics;
class AsGraphicsEvents;
class AsGraphicsController;
class AsGraphicsLineItem;
class AsGraphicsPolylineItem;
class AsGraphicsRotatedRectItem;
class AsGraphicsImageItem;
class AsGraphicsObject;
AS_MEMBER_CLASS_DECLARATION(AsGraphics);
AS_MEMBER_CLASS_DECLARATION(AsGraphicsController);
AS_MEMBER_CLASS_DECLARATION(AsGraphicsEvents);

__AS_JY(Update 2023.1.7)
namespace AsGraphicsNamespace {

	struct CoordSystem {
		enum Enum {
			Graphic,
			Widget,
			Global
		};
	};

	struct DefaultEntrance {
		enum Enum {
			UserBottom,
			ImageViewer,
			VideoDisplayer,
			OptionsPanel,
			GeometricMeasurer,
			RectCreator,
			PolygonCreator,
			Scaleplate,
			UserTop
		};
	};

	struct Key {
		enum Enum {
			None = 0x00000000,
			MouseLeft = 0x00000001,
			MouseRight = 0x00000002,
			MouseMid = 0x00000004,
			MouseBack = 0x00000008,
			MouseForward = 0x00000010,
			Space = 0x20,
			Exclam,
			QuoteDbl,
			NumberSign,
			Dollar,
			Percent,
			Ampersand,
			Apostrophe,
			ParenLeft,
			ParenRight,
			Asterisk,
			Plus,
			Comma,
			Minus,
			Period,
			Slash,
			Num0, Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9,
			Colon, 
			Semicolon,
			Less,
			Equal,
			Greater,
			Question,
			At,
			A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
			BracketLeft,
			Backslash,
			BracketRight,
			AsciiCircum,
			Underscore,
			QuoteLeft,
			BraceLeft = 0x7B,
			Bar,
			BraceRight,
			AsciiTilde,
			F1 = 0x01000030, F2, F3, F4, F5, F6, F7, F8, F9, F10, 
			F11 = 0x0100003A, F12,
			Escape = 0x01000000, 
			Tab,
			Backtab,
			Backspace,
			Return,
			Enter,
			Insert,
			Delete,
			Pause,
			Print,
			SysReq = 0x0100000A,
			Clear,
			Home = 0x01000010,
			End,
			Left,
			Up,
			Right,
			Down,
			PageUp,
			PageDn,
			Shift = 0x01000020,
			Control,
			Meta,
			Alt,
			CapsLock,
			NumLock,
			ScrollLock,
		};
		static QString toString(int key);
	};

	typedef unsigned __int64 ItemOptions;

	enum ItemOption {
		ItemOption_None = 0x00,
		ItemOption_Antialiasing = 0x01,
		ItemOption_KeepPenWidth = 0x02,
		ItemOption_IgnoreTransformation = 0x04,
		ItemOption_TextSingleRow = 0x08,
		ItemOption_ImageSmoothTransformation = 0x10
	};

	const QPen		DefaultPen_Line(QColor(0, 122, 204), 0);
	const QBrush	DefaultBrush_Fill(QColor(0, 122, 204, 64));

	typedef QVector<QPointF> PolylineF;

	class AS_GRAPHICS_API RotatedRect {
	public:
		RotatedRect();
		RotatedRect(const QPointF& center, const QSizeF& size, double angle);

	public:
		QPointF center;
		QSizeF size;
		double angle;

	};

};

namespace AG = AsGraphicsNamespace;

